/**
 * @FileName Originator.java
 * @Package com.designMode.memento
 * -------------------------------------
 * @function Please write description of function
 * @Date 2016-1-19 上午10:32:14
 * -------------------------------------
 * Copyright (c) 2016,顾博君 All Rights Reserved.
 */
package com.designMode.memento;

/**
 * @author 顾博君
 * @ClassName Originator
 * @Date 2016-1-19 上午10:32:14
 * @Function 发起人角色
 */
public class Originator {
    /**
     * 内部状态
     */
    private String state = "init";

    /**
     * 获取状态
     *
     * @return 状态
     */
    public String getState() {
        return state;
    }

    /**
     * 设置状态
     *
     * @param state 状态
     */
    public void setState(String state) {
        this.state = state;
    }

    /**
     * 创建一个备忘录
     *
     * @return 备忘录
     */
    public Memento createMemento() {
        return new Memento(state);
    }

    /**
     * 恢复一个备忘录
     *
     * @param memento 备忘录
     */
    public void restoreMemento(Memento memento) {
        setState(memento.getState());
    }
}
